/**
 */
package OBSL.impl;

import OBSL.ModeCharacterizationLink;
import OBSL.ModeIndividual;
import OBSL.OBSLPackage;

import RefOntoUML.Classifier;
import RefOntoUML.Mode;

import java.lang.reflect.InvocationTargetException;

import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.common.notify.NotificationChain;

import org.eclipse.emf.common.util.EList;
import org.eclipse.emf.common.util.WrappedException;

import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.EOperation;
import org.eclipse.emf.ecore.InternalEObject;

import org.eclipse.emf.ecore.impl.ENotificationImpl;

/**
 * <!-- begin-user-doc -->
 * An implementation of the model object '<em><b>Mode Individual</b></em>'.
 * <!-- end-user-doc -->
 * <p>
 * The following features are implemented:
 * <ul>
 *   <li>{@link OBSL.impl.ModeIndividualImpl#getMode <em>Mode</em>}</li>
 *   <li>{@link OBSL.impl.ModeIndividualImpl#getCharacterizes <em>Characterizes</em>}</li>
 * </ul>
 * </p>
 *
 * @generated
 */
public class ModeIndividualImpl extends PresentIndividualImpl implements ModeIndividual {
	/**
	 * The cached value of the '{@link #getMode() <em>Mode</em>}' reference.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getMode()
	 * @generated
	 * @ordered
	 */
	protected Mode mode;

	/**
	 * The cached value of the '{@link #getCharacterizes() <em>Characterizes</em>}' containment reference.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getCharacterizes()
	 * @generated
	 * @ordered
	 */
	protected ModeCharacterizationLink characterizes;

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected ModeIndividualImpl() {
		super();
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	protected EClass eStaticClass() {
		return OBSLPackage.Literals.MODE_INDIVIDUAL;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public Mode getMode() {
		if (mode != null && mode.eIsProxy()) {
			InternalEObject oldMode = (InternalEObject)mode;
			mode = (Mode)eResolveProxy(oldMode);
			if (mode != oldMode) {
				if (eNotificationRequired())
					eNotify(new ENotificationImpl(this, Notification.RESOLVE, OBSLPackage.MODE_INDIVIDUAL__MODE, oldMode, mode));
			}
		}
		return mode;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public Mode basicGetMode() {
		return mode;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setMode(Mode newMode) {
		Mode oldMode = mode;
		mode = newMode;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, OBSLPackage.MODE_INDIVIDUAL__MODE, oldMode, mode));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public ModeCharacterizationLink getCharacterizes() {
		return characterizes;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public NotificationChain basicSetCharacterizes(ModeCharacterizationLink newCharacterizes, NotificationChain msgs) {
		ModeCharacterizationLink oldCharacterizes = characterizes;
		characterizes = newCharacterizes;
		if (eNotificationRequired()) {
			ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, OBSLPackage.MODE_INDIVIDUAL__CHARACTERIZES, oldCharacterizes, newCharacterizes);
			if (msgs == null) msgs = notification; else msgs.add(notification);
		}
		return msgs;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setCharacterizes(ModeCharacterizationLink newCharacterizes) {
		if (newCharacterizes != characterizes) {
			NotificationChain msgs = null;
			if (characterizes != null)
				msgs = ((InternalEObject)characterizes).eInverseRemove(this, OBSLPackage.MODE_CHARACTERIZATION_LINK__MODE, ModeCharacterizationLink.class, msgs);
			if (newCharacterizes != null)
				msgs = ((InternalEObject)newCharacterizes).eInverseAdd(this, OBSLPackage.MODE_CHARACTERIZATION_LINK__MODE, ModeCharacterizationLink.class, msgs);
			msgs = basicSetCharacterizes(newCharacterizes, msgs);
			if (msgs != null) msgs.dispatch();
		}
		else if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, OBSLPackage.MODE_INDIVIDUAL__CHARACTERIZES, newCharacterizes, newCharacterizes));
	}

	/**
	 * The cached invocation delegate for the '{@link #classifiedBy() <em>Classified By</em>}' operation.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #classifiedBy()
	 * @generated
	 * @ordered
	 */
	protected static final EOperation.Internal.InvocationDelegate CLASSIFIED_BY__EINVOCATION_DELEGATE = ((EOperation.Internal)OBSLPackage.Literals.MODE_INDIVIDUAL___CLASSIFIED_BY).getInvocationDelegate();

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public Classifier classifiedBy() {
		try {
			return (Classifier)CLASSIFIED_BY__EINVOCATION_DELEGATE.dynamicInvoke(this, null);
		}
		catch (InvocationTargetException ite) {
			throw new WrappedException(ite);
		}
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public NotificationChain eInverseAdd(InternalEObject otherEnd, int featureID, NotificationChain msgs) {
		switch (featureID) {
			case OBSLPackage.MODE_INDIVIDUAL__CHARACTERIZES:
				if (characterizes != null)
					msgs = ((InternalEObject)characterizes).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - OBSLPackage.MODE_INDIVIDUAL__CHARACTERIZES, null, msgs);
				return basicSetCharacterizes((ModeCharacterizationLink)otherEnd, msgs);
		}
		return super.eInverseAdd(otherEnd, featureID, msgs);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) {
		switch (featureID) {
			case OBSLPackage.MODE_INDIVIDUAL__CHARACTERIZES:
				return basicSetCharacterizes(null, msgs);
		}
		return super.eInverseRemove(otherEnd, featureID, msgs);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Object eGet(int featureID, boolean resolve, boolean coreType) {
		switch (featureID) {
			case OBSLPackage.MODE_INDIVIDUAL__MODE:
				if (resolve) return getMode();
				return basicGetMode();
			case OBSLPackage.MODE_INDIVIDUAL__CHARACTERIZES:
				return getCharacterizes();
		}
		return super.eGet(featureID, resolve, coreType);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public void eSet(int featureID, Object newValue) {
		switch (featureID) {
			case OBSLPackage.MODE_INDIVIDUAL__MODE:
				setMode((Mode)newValue);
				return;
			case OBSLPackage.MODE_INDIVIDUAL__CHARACTERIZES:
				setCharacterizes((ModeCharacterizationLink)newValue);
				return;
		}
		super.eSet(featureID, newValue);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public void eUnset(int featureID) {
		switch (featureID) {
			case OBSLPackage.MODE_INDIVIDUAL__MODE:
				setMode((Mode)null);
				return;
			case OBSLPackage.MODE_INDIVIDUAL__CHARACTERIZES:
				setCharacterizes((ModeCharacterizationLink)null);
				return;
		}
		super.eUnset(featureID);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public boolean eIsSet(int featureID) {
		switch (featureID) {
			case OBSLPackage.MODE_INDIVIDUAL__MODE:
				return mode != null;
			case OBSLPackage.MODE_INDIVIDUAL__CHARACTERIZES:
				return characterizes != null;
		}
		return super.eIsSet(featureID);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Object eInvoke(int operationID, EList<?> arguments) throws InvocationTargetException {
		switch (operationID) {
			case OBSLPackage.MODE_INDIVIDUAL___CLASSIFIED_BY:
				return classifiedBy();
		}
		return super.eInvoke(operationID, arguments);
	}

} //ModeIndividualImpl
